{"ast":null,"code":"import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport { toPathOptions } from '../utils/treeUtil';\nimport * as React from 'react';\nimport { toPathKey } from '../utils/commonUtil';\nexport default (function (rawValues, options, fieldNames, multiple, displayRender) {\n  return React.useMemo(function () {\n    var mergedDisplayRender = displayRender ||\n    // Default displayRender\n    function (labels) {\n      var mergedLabels = multiple ? labels.slice(-1) : labels;\n      var SPLIT = ' / ';\n      if (mergedLabels.every(function (label) {\n        return ['string', 'number'].includes(_typeof(label));\n      })) {\n        return mergedLabels.join(SPLIT);\n      }\n      // If exist non-string value, use ReactNode instead\n      return mergedLabels.reduce(function (list, label, index) {\n        var keyedLabel = /*#__PURE__*/React.isValidElement(label) ? /*#__PURE__*/React.cloneElement(label, {\n          key: index\n        }) : label;\n        if (index === 0) {\n          return [keyedLabel];\n        }\n        return [].concat(_toConsumableArray(list), [SPLIT, keyedLabel]);\n      }, []);\n    };\n    return rawValues.map(function (valueCells) {\n      var _valueOptions, _valueOptions$option;\n      var valueOptions = toPathOptions(valueCells, options, fieldNames);\n      var label = mergedDisplayRender(valueOptions.map(function (_ref) {\n        var _option$fieldNames$la;\n        var option = _ref.option,\n          value = _ref.value;\n        return (_option$fieldNames$la = option === null || option === void 0 ? void 0 : option[fieldNames.label]) !== null && _option$fieldNames$la !== void 0 ? _option$fieldNames$la : value;\n      }), valueOptions.map(function (_ref2) {\n        var option = _ref2.option;\n        return option;\n      }));\n      var value = toPathKey(valueCells);\n      return {\n        label: label,\n        value: value,\n        key: value,\n        valueCells: valueCells,\n        disabled: (_valueOptions = valueOptions[valueOptions.length - 1]) === null || _valueOptions === void 0 ? void 0 : (_valueOptions$option = _valueOptions.option) === null || _valueOptions$option === void 0 ? void 0 : _valueOptions$option.disabled\n      };\n    });\n  }, [rawValues, options, fieldNames, displayRender, multiple]);\n});","map":{"version":3,"names":["_toConsumableArray","_typeof","toPathOptions","React","toPathKey","rawValues","options","fieldNames","multiple","displayRender","useMemo","mergedDisplayRender","labels","mergedLabels","slice","SPLIT","every","label","includes","join","reduce","list","index","keyedLabel","isValidElement","cloneElement","key","concat","map","valueCells","_valueOptions","_valueOptions$option","valueOptions","_ref","_option$fieldNames$la","option","value","_ref2","disabled","length"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/rc-cascader/es/hooks/useDisplayValues.js"],"sourcesContent":["import _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nimport _typeof from \"@babel/runtime/helpers/esm/typeof\";\nimport { toPathOptions } from '../utils/treeUtil';\nimport * as React from 'react';\nimport { toPathKey } from '../utils/commonUtil';\nexport default (function (rawValues, options, fieldNames, multiple, displayRender) {\n  return React.useMemo(function () {\n    var mergedDisplayRender = displayRender ||\n    // Default displayRender\n    function (labels) {\n      var mergedLabels = multiple ? labels.slice(-1) : labels;\n      var SPLIT = ' / ';\n      if (mergedLabels.every(function (label) {\n        return ['string', 'number'].includes(_typeof(label));\n      })) {\n        return mergedLabels.join(SPLIT);\n      }\n      // If exist non-string value, use ReactNode instead\n      return mergedLabels.reduce(function (list, label, index) {\n        var keyedLabel = /*#__PURE__*/React.isValidElement(label) ? /*#__PURE__*/React.cloneElement(label, {\n          key: index\n        }) : label;\n        if (index === 0) {\n          return [keyedLabel];\n        }\n        return [].concat(_toConsumableArray(list), [SPLIT, keyedLabel]);\n      }, []);\n    };\n    return rawValues.map(function (valueCells) {\n      var _valueOptions, _valueOptions$option;\n      var valueOptions = toPathOptions(valueCells, options, fieldNames);\n      var label = mergedDisplayRender(valueOptions.map(function (_ref) {\n        var _option$fieldNames$la;\n        var option = _ref.option,\n          value = _ref.value;\n        return (_option$fieldNames$la = option === null || option === void 0 ? void 0 : option[fieldNames.label]) !== null && _option$fieldNames$la !== void 0 ? _option$fieldNames$la : value;\n      }), valueOptions.map(function (_ref2) {\n        var option = _ref2.option;\n        return option;\n      }));\n      var value = toPathKey(valueCells);\n      return {\n        label: label,\n        value: value,\n        key: value,\n        valueCells: valueCells,\n        disabled: (_valueOptions = valueOptions[valueOptions.length - 1]) === null || _valueOptions === void 0 ? void 0 : (_valueOptions$option = _valueOptions.option) === null || _valueOptions$option === void 0 ? void 0 : _valueOptions$option.disabled\n      };\n    });\n  }, [rawValues, options, fieldNames, displayRender, multiple]);\n});"],"mappings":"AAAA,OAAOA,kBAAkB,MAAM,8CAA8C;AAC7E,OAAOC,OAAO,MAAM,mCAAmC;AACvD,SAASC,aAAa,QAAQ,mBAAmB;AACjD,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,gBAAgB,UAAUC,SAAS,EAAEC,OAAO,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,aAAa,EAAE;EACjF,OAAON,KAAK,CAACO,OAAO,CAAC,YAAY;IAC/B,IAAIC,mBAAmB,GAAGF,aAAa;IACvC;IACA,UAAUG,MAAM,EAAE;MAChB,IAAIC,YAAY,GAAGL,QAAQ,GAAGI,MAAM,CAACE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAGF,MAAM;MACvD,IAAIG,KAAK,GAAG,KAAK;MACjB,IAAIF,YAAY,CAACG,KAAK,CAAC,UAAUC,KAAK,EAAE;QACtC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAACC,QAAQ,CAACjB,OAAO,CAACgB,KAAK,CAAC,CAAC;MACtD,CAAC,CAAC,EAAE;QACF,OAAOJ,YAAY,CAACM,IAAI,CAACJ,KAAK,CAAC;MACjC;MACA;MACA,OAAOF,YAAY,CAACO,MAAM,CAAC,UAAUC,IAAI,EAAEJ,KAAK,EAAEK,KAAK,EAAE;QACvD,IAAIC,UAAU,GAAG,aAAapB,KAAK,CAACqB,cAAc,CAACP,KAAK,CAAC,GAAG,aAAad,KAAK,CAACsB,YAAY,CAACR,KAAK,EAAE;UACjGS,GAAG,EAAEJ;QACP,CAAC,CAAC,GAAGL,KAAK;QACV,IAAI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